define(["require", "exports", "../utils/strings", "url"], function (require, exports, strings_1, url) {
    'use strict';
    Object.defineProperty(exports, "__esModule", { value: true });
    function getDocumentContext(documentUri, workspaceFolders) {
        function getRootFolder() {
            for (let folder of workspaceFolders) {
                let folderURI = folder.uri;
                if (!strings_1.endsWith(folderURI, '/')) {
                    folderURI = folderURI + '/';
                }
                if (strings_1.startsWith(documentUri, folderURI)) {
                    return folderURI;
                }
            }
            return void 0;
        }
        return {
            resolveReference: (ref, base = documentUri) => {
                if (ref[0] === '/') {
                    if (strings_1.startsWith(base.toString(), 'file://')) {
                        let folderUri = getRootFolder();
                        if (folderUri) {
                            return folderUri + ref.substr(1);
                        }
                    }
                }
                return url.resolve(base.toString(), ref);
            },
        };
    }
    exports.getDocumentContext = getDocumentContext;
});
